package com.lft06.lambdaexpression;

/**
 * Function: 		A {@code TestLambda} object With Some FUNCTION.<br/>
 * Reason:   		ADD REASON.<br/>
 * Date:            2021-01-27 13:02<br/>
 * <p>
 * Class Name:      TestLambda<br/>
 * Package Name:    com.lft06.lambdaexpression<br/>
 * @author Laifengting / E-mail:laifengting@foxmail.com
 * @version 1.0.0
 * @since JDK 8
 */
public class TestLambda {
	/**
	 * 2. 静态内部类
	 */
	static class Like2 implements ILike {
		@Override
		public void like() {
			System.out.println("我喜欢 lambda2 静态内部类...");
		}
	}
	
	public static void main(String[] args) {
		ILike like = new Like();
		like.like();
		
		like = new Like2();
		like.like();
		
		/**
		 * 3. 局部内部类
		 */
		class Like3 implements ILike {
			@Override
			public void like() {
				System.out.println("我喜欢 lambda3 局部内部类...");
			}
		}
		like = new Like3();
		like.like();
		
		/**
		 * 4. 匿名内部类
		 */
		like = new ILike() {
			@Override
			public void like() {
				System.out.println("我喜欢 lambda4 匿名内部类...");
			}
		};
		like.like();
		
		/**
		 * 5. lambda 表达式
		 */
		like = () -> System.out.println("我喜欢 lambda5 lambda 表达式...");
		like.like();
	}
}

/**
 * 定义一个函数式接口（只有唯一一个抽象方法）
 */
interface ILike {
	void like();
}

/**
 * 1. 外部实现类
 */
class Like implements ILike {
	@Override
	public void like() {
		System.out.println("我喜欢 lambda1 外部定义的类...");
	}
}